import {reactive, ref} from 'vue';
import { defineStore } from 'pinia'

/**
 * 用于存放用户相关的信息
 *
 */

export const useUserStore = defineStore(
    'user',
    () => {

        /**
         * 登录凭证实体
         */
        const jwtEntity = reactive({
            jwt: '',
            signKeyStr: '',
        })
        const updateJwt = (jwt) => {
            jwtEntity.jwt = jwt.jwt;
            jwtEntity.signKeyStr = jwt.signKeyStr;
        }
        const removeJwt = () => {
            jwtEntity.jwt = '';
            jwtEntity.signKeyStr = '';
        }

        return {
            jwtEntity,updateJwt,removeJwt,
        }
    },
    {
        persist: true
    }
)